package com.kiki.stater.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by mazeyi on 2021/2/25.
 */
public class LeetcodeTest {

    public static String convert(String s, int numRows) {
        if (numRows == 1) return s;

        List<StringBuilder> rows = new ArrayList<>();
        for (int i = 0; i < Math.min(numRows, s.length()); i++)
            rows.add(new StringBuilder());

        int curRow = 0;
        boolean goingDown = false;

        for (char c : s.toCharArray()) {
            rows.get(curRow).append(c);
            if (curRow == 0 || curRow == numRows - 1) goingDown = !goingDown;
            curRow += goingDown ? 1 : -1;
        }

        StringBuilder ret = new StringBuilder();
        for (StringBuilder row : rows) ret.append(row);
        return ret.toString();
    }


    public static int reverse(int x){
        int result = 0;

        while (x != 0){
            if ((result * 10) / 10 != result) {
                result = 0;
                break;
            }
            result = result * 10 + x % 10;
            x = x/10;
        }

        System.out.println(result);
        return 0;
    }

    public static void main(String[] args) {
       reverse(123);
    }

}